<!-- 设备档案 -->
<template>
  <div>
    <a-table
      bordered
      rowKey="id"
      :columns="_d.table.head"
      :data-source="_d.table.data"
      :pagination="_d.paging"
      :loading="_d.table.loading"
      :row-selection="{
        selectedRowKeys: _d.table.selected,
        getCheckboxProps: getCheckboxProps,
        onChange: onSelectChange,
      }">
    </a-table>
  </div>
</template>

<script setup>
import { reactive, ref, onMounted } from "vue";

const updateModalRef = ref();
const _d = reactive({
  selectedRows: [], //选中的对象
  table: {
    loading: false,
    head: [
      { title: "设备所在区域", dataIndex: "areaName", ellipsis: true },
      { title: "出厂编号", dataIndex: "factoryNumber", ellipsis: true },
      { title: "使用状态", dataIndex: "equipmentState", ellipsis: true },
      { title: "安全员", dataIndex: "annStaff", ellipsis: true },
      { title: "安全员电话", dataIndex: "annStaffPhone", ellipsis: true },
      { title: "使用登记证编号", dataIndex: "useCardNumber", ellipsis: true },
    ],
    data: [],
    selected: [],
  },

  paging: {
    current: 1,
    pageSize: 10,
    total: 0,
    showSizeChanger: true,
    pageSizeOptions: ["10", "20", "50", "100"],
    showTotal: (total) => `共 ${total} 条`,
    onChange(current, pageSize) {
      this.current = current;
      this.pageSize = pageSize;
      _d.form.pageCurrent = current;
      _d.form.pageRows = pageSize;
      getData();
    },
  },
});

onMounted(() => {

});

// 获取能否选择
function getCheckboxProps(record) {
  return {
    disabled: record.id == '1' ? true : false
  }
}

function onSelectChange(selectedRowKeys, selectedRows) {
  _d.table.selected = selectedRowKeys;
  _d.selectedRows = selectedRows;
}
</script>

<style lang="less" scoped>
</style>